home *** CD-ROM | disk | FTP | other *** search
- /****************************************/
-
- /* IsThereDTPrinter.c */
- /* Author: Shemin Gau, IP */
- /* Revision History: 02/03/94 */
-
- /****************************************/
-
-
- #include <Memory.h>
- #include <Resources.h>
- #include <Types.h>
- #include <String.h>
- #include <OSUtils.h>
- #include <ToolUtils.h>
- #include <Errors.h>
-
-
- OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize);
-
-
- pascal OSErr main(char msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
- {
- Handle my_hndl;
- short old_file = CurResFile();
- char *str_holder = '\0';
- OSErr my_err = noErr;
-
- Boolean result = false;
-
-
- UseResFile(0);
-
- //It is not a right way to pass the id directly. But it's a unique number, I did it anyway.
-
- if (my_hndl = (Handle)Get1Resource('STR ', -8192)) {
- BlockMove(*my_hndl, str_holder, (long)(**my_hndl + 1));
- } else {
- my_err = ResError();
- }
- ReleaseResource((Handle)my_hndl);
-
- //This one is really tricky, the handle is actually a pointer to the 'STR ',
- //plus a control character.
-
- UseResFile(old_file);
- if ((*str_holder) && (my_err == noErr)) {
- result = true;
- my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(my_err);
- } else {
- //return(1); /* False */
- my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(my_err);
- }
-
- }
-
-
- OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize)
- {
- Ptr p;
-
- if (p = NewPtr(theSize)) {
- BlockMove(theData, p, theSize);
-
- *outSize = theSize;
- *outMessage = p;
-
- return(noErr);
- } else {
- return(MemError());
- }
- }
-
-